package org.hishen.example.entity.system;

import java.util.Set;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hishen.example.entity.AbstractBaseEntity;

import com.fasterxml.jackson.annotation.JsonIgnore;

/**
 * 菜单实体类
 * @author ZhangDi
 *
 */
@Entity
@Table(name = "system_menu")
public class Menu extends AbstractBaseEntity {
	
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Integer id;
	
	private String name;
		
	private String url;
	
	@OneToMany(mappedBy = "parent", fetch = FetchType.EAGER)
	private Set<Menu> children;
	
	@ManyToOne
	@JsonIgnore
	private Menu parent;
	
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Menu getParent() {
		return parent;
	}

	public void setParent(Menu parent) {
		this.parent = parent;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public Set<Menu> getChildren() {
		return children;
	}

	public void setChildren(Set<Menu> children) {
		this.children = children;
	}
}
